#include <iostream>
#include <unordered_map>
using namespace std;
unordered_map<int, int> h;
int main() {
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++) {
        int temp;
        cin >> temp;
        h[temp] = i;
    }
    int k;
    cin >> k;
    for(int i = 0; i < k; i++) {
        int temp;
        cin >> temp;
        if(h.find(temp) == h.end()) {
            cout << 0 << endl;
        }else {
            cout << h[temp] << endl;
        }
    }
    return 0;
}